/*
 * Copyright 2019 WeBank
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.webank.wedatasphere.qualitis.project.entity;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * @author howeye
 */
@Entity
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "@id")
@Table(name = "qualitis_mulu")
public class ProjectMuLu implements Serializable {

    private static final long serialVersionUID = -429065239198706646L;

    public String toString() {
        return "ProjectMuLu{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", parentId=" + parentId +
                ", spread='" + spread + '\'' +
                ", title='" + title + '\'' +
                ", children=" + children +
                '}';
    }

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    @Column(length = 170)
    private String name;
    @Column(name = "parent_id")
    private Long parentId;
    @Column(length = 50)
    private String spread;

    @Column(name = "title", length = 50)
    private String title;


    @Transient
    private List<ProjectMuLu> children;

    public List<ProjectMuLu> getChildren() {
        return children;
    }

    public void setChildren(List<ProjectMuLu> children) {
        this.children = children;
    }

    public ProjectMuLu() {
    }

    public ProjectMuLu(Long id, String name, Long parentId, String spread, String title) {
        this.id = id;
        this.name = name;
        this.parentId = parentId;
        this.spread = spread;
        this.title = title;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getParentId() {
        return parentId;
    }

    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    public String getSpread() {
        return spread;
    }

    public void setSpread(String spread) {
        this.spread = spread;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }
}
